package com.lx.patterns.interpreter;

/**
 * @ClassName Plus
 * @Description: 加法表达式
 * @Author: 落雪
 * @CreateDate: 2025/2/15 16:20
 * @UpdateUser: 落雪
 * @UpdateDate: 2025/2/15 16:20
 * @UpdateRemark:
 * @Version: 1.0
 */
public class Minus implements AbstractExpression{

    private AbstractExpression left;

    private AbstractExpression right;

    public Minus(AbstractExpression left, AbstractExpression right) {
        this.left = left;
        this.right = right;
    }
    @Override
    public int interpret(Context context) {
        return left.interpret(context)-right.interpret(context);
    }

    @Override
    public String toString() {
        return "(" + left.toString() + " - " + right.toString() + ")";
    }

}
